<?php
	require 'facebook.php';
	$facebook = new Facebook(array(
		'appId'  => '206809464143',
		'secret' => '310449026673b11ee850f44ee91e9b4d',
		'cookie' => true,
		'fileUpload' => true
	));
	
	$app_name	= 'zg-zing';
	$session = $facebook->getSession();
	$me	= null;
	if ($session) {
		try {
			$uid	= $facebook->getUser();
			$me		= $facebook->api('/me');
		} catch (FacebookApiException $e) {
			error_log($e);
		}
	}else {
		$redirect = $facebook->getLoginUrl(array(
			'canvas'=>0,
			'fbconnect'=>1,
			'req_perms'=>'email,publish_stream,status_update,user_photos,friends_photos',
			'cancel_url'=>'http://vaio.sony.co.th/vaio-box/box-of-happiness/',
			'next'=>'http://vaio.sony.co.th/vaio-box/box-of-happiness/'
		));
		header("location: $redirect");
		exit;
	}
?>